# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: liara <liara@archlinux.email>

pkgname=python-shodan
_pkgname="${pkgname#python-}"
pkgver=1.30.1
pkgrel=1
pkgdesc='The official Python library and CLI for Shodan'
url='https://shodan.readthedocs.io/'
license=('MIT')
arch=('any')
depends=(
  'python'
  'python-click'
  'python-click-plugins'
  'python-colorama'
  'python-xlsxwriter'
  'python-requests'
  'python-setuptools'
  'python-tldextract'
)
makedepends=(
  'python-build'
  'python-installer'
  'python-wheel'
)
optdepends=('python-ujson: faster JSON decoding')
source=("$pkgname-$pkgver.tar.gz::https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
b2sums=('21ef6f4ae2fd6a487e478627f8623dde4e2092fe9dec893e443fc27e94dc3e65a3483317c6819c947f053542414babcfa57ddb82c40f8a83d43bd9e2d9e84d44')

build() {
  cd "$_pkgname-$pkgver"

  python -m build --wheel --no-isolation
}

package() {
  cd "$_pkgname-$pkgver"

  python -m installer --destdir="$pkgdir" dist/*.whl

  # symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir/usr/share/licenses/$pkgname"
  ln -s "$site_packages/${pkgname#python-}-$pkgver.dist-info/LICENSE" \
    "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
